export function join(array: any[], sep = ',', defaultValue = ''): string {
  if (array == null || !Array.isArray(array)) return defaultValue
  const result = []
  for (const element of array) {
    result.push(element)
  }
  return result.join(sep)
}

export function joinNumber(array: any[], precision = 2, sep = ',', defaultValue = ''): string {
  if (array == null || !Array.isArray(array)) return defaultValue
  const result = []
  for (const element of array) {
    result.push(Number(element).toFixed(precision))
  }
  return result.join(sep)
}

/**
 * 一处理类特殊字符串(comma string comma)函数: [1,2,3] => ,1,2,3,
 * @param array
 * @param sep
 * @param defaultValue
 * @returns {string|null}
 */
export function joinCSC(array: any[], sep = ",", defaultValue = ''): string {
  if (array == null || array.length === 0) return defaultValue
  return sep + array.join(sep) + sep
}
